<?php

class CsvUploadForm extends sfForm
{

	public function setup()
	{
		$delimiters = array(',' => 'Coma (,)', ';' => 'Punto y coma (;)');

		$this->setWidgets(array(
			'file' => new sfWidgetFormInputFile(),
			'delimiter' => new sfWidgetFormChoice(array('choices' => $delimiters))
		));

		$this->widgetSchema['file']->setOption('label', 'Archivo');
		$this->widgetSchema['delimiter']->setOption('label', 'Delimitador');

		//$this->widgetSchema->setHelp('file', 'Archivo en formato csv');
		//$this->widgetSchema->setHelp('delimiter', 'Caracter que separa las columnas');

		$this->setValidators(array(
			'file' => new sfValidatorFile(array('mime_types' => array('text/plain'), 'required' => true)),
			'delimiter' => new sfValidatorChoice(array('choices' => array_keys($delimiters), 'required' => true))
		));

		$this->widgetSchema->setNameFormat('upload[%s]');
	}

}